<template>
    <div style="position: fixed;min-width: 60%;left: 50%;top: 40%;transform: translate(-50%,-50%)">
        <div style="display: flex;justify-content: center;font-weight: 600;font-size: 40px">CNN&LSTM模型股票分析系统
        </div>
        <div style="margin-top: 30px;display: flex;justify-content: center">
            <el-row style="max-width:400px">
                <el-col :span="24" style="display: flex;align-items: center;padding: 20px 0" class="">
                    <span style="flex: 0 0 auto;margin-right: 30px">账号:</span>
                    <el-input v-model="username" placeholder="请输入账号"/>

                </el-col>
                <el-col :span="24" style="display: flex;align-items: center;padding: 20px 0">
                    <span style="flex: 0 0 auto;margin-right: 30px">密码:</span>
                    <el-input v-model="password" placeholder="请输入密码"/>

                </el-col>
                <el-col :span="24" style="padding: 20px 0;">
                    <el-button :loading="loading" type="success" size="large" style="width: 100%" @click="handlerLogin">
                        登录
                    </el-button>
                </el-col>
                <el-col :span="24" style="">
                    <el-button type="default" size="large" style="width: 100%" @click="fastLogin">
                        使用root账号登录
                    </el-button>
                </el-col>
            </el-row>
        </div>
    </div>
</template>
<script setup>
import {useRouter, useRoute} from 'vue-router'
import {getCurrentInstance, onMounted, ref} from 'vue'
import {ElNotification} from "element-plus";

const router = useRouter()

const loading = ref(false)
const username = ref('')
const password = ref('')

const fastLogin = () => {
    username.value = 'root'
    password.value = 'root'
}
const handlerLogin = () => {

    loading.value = true
    try {
        if (username.value == "" || password.value == "") {

            ElNotification({
                title: '提示',
                message: '账号和密码不能为空',
                type: 'warning',
            })
            return
        }
        if (username.value != "root" || password.value != "root") {
            ElNotification({
                title: '提示',
                message: '账号和密码错误',
                type: 'warning',
            })
            return
        }
        router.push({
            path: "/index"
        })


    } catch (e) {
    } finally {
        setTimeout(() => {
            loading.value = false
        }, 1000)
    }
}
</script>
<style scoped>

</style>
